package com.example.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

public class DataInit extends SQLiteOpenHelper {

    public DataInit(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        /*
         1. 用户表
            uid(key) uname(varchar 20) pwd(varchar 20) login_ip(varchar 20)
         2. 好友表
            id(key) uid(int) fid(int)
         3. 消息表
            mid(key) uid(int)(发送者） fid(int)
            msg(varchar 255)
            type(int 区分消息类型 0:服务器 1:P2P)
            status(int 0:未读 1：已读）
            send_time(timestamp 发送时间)
         */

        //创建表的SQL语句
//        db.execSQL(TableConstant.INIT_USER);
//        db.execSQL(TableConstant.INIT_FRIEND);
//        db.execSQL(TableConstant.INIT_MESSAGE);
        Log.d("DataBase","数据库创建了");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.d("DataBase","数据库升级了");
    }
}
